<template>
	<view class="mainContent" v-if="listData">
		<view class="listMular" v-if="listData.length > 0">
			<uni-swipe-action>
				<view class="box" v-for="(item,index) in listData" :key="index">
					<image src="@/static/img/monitor/healthStatus/number@2x.png" class="sn"></image>
					<uni-swipe-action-item>
						<view class="top">
							<text class="assementNumber">{{item.sn ? item.sn : '评估编号'}}</text>
							<text>{{item.assessmentDate}}</text>
						</view>
						<view class="bottom">
							<view class="nameBox">
								<text class="userName">{{item.userName || ''}}</text>
								<image src="../../static/img/healthStatus/summary.png"></image>
								<text class="healthName">{{item.userHealthName || ''}}</text>
							</view>
							<view class="buttonBox">	
								<view class="qsDetail" @click="detail(item)">详情</view>
								<view class="viewAssessment" @click="read(item)">查看报告</view>
							</view>
						</view>
					</uni-swipe-action-item>					
				</view>
			</uni-swipe-action>		
		</view>
		<view class="noData" v-else>
			<image src="@/static/img/healthStatus/none.png"></image>
			<view>您还没有评估文件~</view>
		</view>
	</view>
</template>

<script>
	export default{
		data() {
			return {
				pageIndex:1,
				pageSize:20,
				listData:[],
				nullData: false,
				page:1,
			}
		},
		onLoad() {
			this.getList({pageIndex:this.pageIndex,pageSize:this.pageSize,type:2})
		},
		
		onReachBottom() {
			if(this.nullData == true){
				return;
			}
			this.page = this.page + 1
			this.getList({pageIndex:this.page,pageSize:this.pageSize,type:2})
		},
		methods:{
			detail(e) {
				uni.navigateTo({
					url:'/pages/futureSummary/toView?id='+e.id
				})
			},
			getList(data) {
				this.$api.appHealthAssessSummaryList(data).then((res) => {
					if(res.data.returnCode == 200) {
						var data = res.data.result && res.data.result.elements;
						this.listData = this.listData ? this.listData.concat(data) : data;
						if(this.listData.length >= res.data.result.totalCount){
							this.nullData = true;
						}
					}
					
				})
			},
			read(e) {
				if(e.url) {
					window.location.href = 'http://health.jlm12580.com/web/viewer.html?file=' + e.url
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/css/healthStatus/navigation.scss';
	.listMular{
		margin-top: 0 !important;
	}
	/deep/ .uni-swipe_box{
		display: block !important;
	}
	/deep/.uni-swipe_button{
		padding: 0 20rpx;
		margin-left: 10rpx;
	}
</style>
